#include <stdio.h>
#include <vector>
#define bigger(a,b) (a)>(b)?(a):(b)
using namespace std;
int n;

vector < vector <int> > shu;

int ans[102];

int main()
{
	int i, j, a;
 	
    while (scanf("%d", &n)!=EOF)
    {
        shu.resize(n+1);
        for (i=1; i<=n; ++i)
        {
            shu[i].reserve(i+1);
            shu[i].push_back(0);
        	for (j=1; j<=i; ++j)
        	{
       		    scanf("%d", &a);
       		    shu[i].push_back(a);
       		}    
        }  		
     
        for (i=1; i<=n; ++i)
        	ans[i] = shu[n][i];

       	for (i=n-1; i>=1; --i)
       		for (j=1; j<=i; ++j)
       			ans[j] = shu[i][j] + (bigger(ans[j], ans[j+1]));
    	printf("%d\n", ans[1]);
    	shu.clear();
   	}   			
           
        
    
}   
 
